<?php 
	include('../conn.php');
	$result_data_array = array();
	function check($filds,$msg){
		if(!$filds){
			$result_data_array['code'] = -100;
			$result_data_array['msg'] = $msg;
			echo json_encode($result_data_array);
			exit;
		}

	}

	
	//$tel = $_REQUEST['tel'];
	$password = $_REQUEST['password'];
	$head_pic = $_REQUEST['head_pic'];
	$name = $_REQUEST['name'];
	$phone = $_REQUEST['phone'];
	$alipay = $_REQUEST['alipay'];
	$qq = $_REQUEST['qq'];
	$address = $_REQUEST['address'];
	$lon = $_REQUEST['lon'];
	$lat = $_REQUEST['lat'];
	$aliname = $_REQUEST['aliname'];
	$wechatpay = $_REQUEST['wechatpay'];
	$wechatname = $_REQUEST['wechatname'];
	$huodong_miaoshu = $_REQUEST['huodong_miaoshu'];
	$vr_dizhi = $_REQUEST['vr_dizhi'];
	$wenzi_miaoshu = $_REQUEST['wenzi_miaoshu'];
	$jiage_miaoshu = $_REQUEST['jiage_miaoshu'];
	$content = $_REQUEST['content'];
	$city = $_REQUEST['city'];
	$srcimages = $_REQUEST['srcimages'];
	$images = $_REQUEST['images'];
	$leimu = $_REQUEST['leimu'];
	$zileimu = $_REQUEST['zileimu'];
	$rate = $_REQUEST['rate'];
	$freight_ins = $_REQUEST['freight_ins'];
	$htservice = $_REQUEST['htservice'];
	$licence = $_REQUEST['licence'];

/*	check($tel,'注册异常');
	check($password,'注册异常');
	check($name,'店铺名称不能为空');
	check($phone,'联系手机号不能为空');
	check($lon,'经纬度不能为空');
	check($lat,'经纬度不能为空');
	check($alipay,'支付宝账号');
	check($aliname,'支付宝收款人不能为空');
	check($wechatpay,'微信号不能为空');
	check($wechatname,'微信收款人不能为空');
	check($huodong_miaoshu,'活动描述不能为空');
	check($wenzi_miaoshu,'商家标签不能为空');
	check($jiage_miaoshu,'折扣描述不能为空');
	check($city,'社区不能为空');
	check($images,'商家主图不能为空');
	check($srcimages,'商家主图不能为空');
	check($head_pic,'头像不能为空');
	check($leimu,'商家分类不能为空');
	check($zileimu,'商家子分类不能为空');
	check($licence,'营业执照不能为空');*/

	$sql = "INSERT INTO shop(shop_daima,password,head_pic,name,phone,alipay,qq,address,longitude,latitude,alipay_name,weipay,weipay_name,huodong_miaoshu,vr_dizhi,wenzi_miaoshu,jiage_miaoshu,content,city,srcimages,images,leimu,zileimu,freight_ins,htservice,licence) values('".$phone."','".$password."','".$head_pic."','".$name."','".$phone."','".$alipay."','".$qq."','".$address."','".$lon."','".$lat."','".$aliname."','".$wechatpay."','".$wechatname."','".$huodong_miaoshu."','".$vr_dizhi."','".$wenzi_miaoshu."','".$jiage_miaoshu."','".$content."','".$city."','".$srcimages."','".$images."','".$leimu."','".$zileimu."','".$freight_ins."','".$htservice."','".$licence."')";
	
	$query = mysql_query($sql);
	$shopid = mysql_insert_id();
	if(!$query || !$shopid){
		$result_data_array['code'] = -100;
		$result_data_array['msg'] = '修改失败';
		echo json_encode($result_data_array);
		exit;
	}

	$conn = mysql_connect('localhost','root','');
	mysql_select_db('xzpf');

	// 向e网生活的商家添加数据
	$query = mysql_query("INSERT INTO user (phone,password,userid,xzsh_shopid) VALUES ('$tel','$password','$shopid','$shopid')");
	$xzpf_userid = mysql_insert_id();
	// 向e网生活的商家添加数据 end

	$conn=mysql_connect('localhost','root','');
	mysql_select_db('xzsh');
	$query = mysql_query("UPDATE shop set xzpf_userid = ".$xzpf_userid." where shopid = ".$shopid);

	$result_data_array['code'] = 200;
	$result_data_array['msg'] = '修改成功';
	$result_data_array['shopid'] = $shopid;
	echo json_encode($result_data_array);

 ?>